package com.situ.feemanagement.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.situ.feemanagement.mapper.MedicineMapper;
import com.situ.feemanagement.pojo.entity.Medicine;
import com.situ.feemanagement.pojo.vo.MedicineExcelVO;
import org.springframework.beans.BeanUtils;

public class MedicineExcelListener extends AnalysisEventListener<MedicineExcelVO> {

    private MedicineMapper medicineMapper;

    public MedicineExcelListener(MedicineMapper medicineMapper) {
        this.medicineMapper = medicineMapper;
    }

    @Override
    public void invoke(MedicineExcelVO medicineExcelVO, AnalysisContext analysisContext) {
        System.out.println("MedicineExcelListener.invoke");
        Medicine medicine = new Medicine();
        BeanUtils.copyProperties(medicineExcelVO, medicine);
        medicineMapper.addExcel(medicine);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
